﻿namespace Editor
{
    using System;
    using System.IO;
    using System.Reflection;

    using EFMLEditor;
    using EFMLEditor.Internal;
    using EFMLEditor.Properties;

    using Application = System.Windows.Forms.Application;

    internal static class Program
    {
        public static EditorPlugInManager _plugInManager;
        /// <summary>
        /// 	Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SplashScreen.BeginDisplay();
            SplashScreen.SetBackgroundImage(Resources.splash);

            var frm = new Start();
            var main = new Form1();

            _plugInManager = new EditorPlugInManager(main) { PlugInFolder = Path.Combine(GetCurrentDirectory(), "PlugIns") };

            UpdateController.Init();
            UpdateController.Check();

            //Load all plugins
            _plugInManager.LoadPlugIns();

            SplashScreen.EndDisplay();

            Application.Run(frm);
        }
        private static string GetCurrentDirectory()
        {
            try
            {
                return (new FileInfo(Assembly.GetExecutingAssembly().Location)).Directory.FullName;
            }
            catch (Exception)
            {
                return Directory.GetCurrentDirectory();
            }
        }
    }
}